<?php

/**
 * 计划任务消息通知
 * File Name：MessageController.php
 * File Encoding：UTF-8
 * File New Time：2014-10-6 10:52:54
 * Author：水平凡
 * Mailbox：admin@abc3210.com
 */
class MessageController extends YzwController {

    public function actionIndex() {
        set_time_limit(600);
        header("Content-type: text/html; charset=utf-8");
        $data = array();
        //从redis读取50条
        for ($i = 0; $i < 50; $i++) {
            $infoList = RedisCluster::getInstance()->pop('snsMessage');
            if (!empty($infoList)) {
                $data[] = $infoList;
            }
        }
        print_r($data);
        //发送站内通知
        foreach ($data as $key => $info) {
            if (empty($info) || !is_array($info)) {
                continue;
            }
            MessageModel::model()->sendNotice($info['uid'], $info['sendUser'], $info['typeId'], $info['extendParams']);
        }
        echo "<br/>发送完毕！";
    }

}
